package models

import (
	"time"

	"gddgame.cc/galaxy/common"
	. "gddgame.cc/galaxy/common/dsl/db"
	"gddgame.cc/galaxy/utils/orm"
)

var (
	ManagerModel = orm.NewModel("manager", &Manager{}, nil)
)

func init() {
	AddTable(&Table{
		Model: ManagerModel,
	})
}

type Manager struct {
	Id       int    `json:"id" orm:"auto" sql:"INT"`
	Username string `json:"username" sql:"VARCHAR"`
	Password string `json:"-" hidden:"password" sql:"VARCHAR"`
	Token    string `json:"token" sql:"VARCHAR"`

	CreateTime *time.Time `json:"create_time" orm:"createTime" sql:"DATETIME"`
	UpdateTime *time.Time `json:"update_time" orm:"updateTime" sql:"DATETIME"`
	DeleteTime *time.Time `json:"delete_time" orm:"deleteTime" sql:"DATETIME"`
}

func (manager *Manager) FormatPassword(password string) string {
	return common.Md5(common.Md5(password) + password)
}
